switch: Put the slider node last
authorTimm Bäder <mail@baedert.org>
Wed, 28 Jun 2017 13:57:42 +0000 (15:57 +0200)
committerMatthias Clasen <mclasen@redhat.com>
Thu, 20 Jul 2017 01:27:15 +0000 (21:27 -0400)
Makes sense since we draw it over both labels. Also make this obvious by
using the default snapshot implementation.

gtk/gtkswitch.c

index db6fd478093d37e8f038c75f7895bdcf45afa741..bddd46fa2615104f4aa471b62a9bfbeaf13016d7 100644 (file)
@@ -40,9 +40,9 @@
  *
  * |[<!-- language="plain" -->
  * switch
- * ├── slider
  * ├── label
- * ╰── label
+ * ├── label
+ * ╰── slider
  * ]|
  *
  * GtkSwitch has four css nodes, the main node with the name switch and subnodes
@@ -369,17 +369,6 @@ gtk_switch_size_allocate (GtkWidget     *widget,
   gtk_widget_set_clip (widget, &clip);
 }
 
-static void
-gtk_switch_snapshot (GtkWidget   *widget,
-                     GtkSnapshot *snapshot)
-{
-  GtkSwitchPrivate *priv = GTK_SWITCH (widget)->priv;
-
-  gtk_widget_snapshot_child (widget, priv->on_label, snapshot);
-  gtk_widget_snapshot_child (widget, priv->off_label, snapshot);
-  gtk_widget_snapshot_child (widget, priv->slider, snapshot);
-}
-
 static void
 gtk_switch_set_action_name (GtkActionable *actionable,
                             const gchar   *action_name)
@@ -571,7 +560,6 @@ gtk_switch_class_init (GtkSwitchClass *klass)
 
   widget_class->measure = gtk_switch_measure;
   widget_class->size_allocate = gtk_switch_size_allocate;
-  widget_class->snapshot = gtk_switch_snapshot;
 
   klass->activate = gtk_switch_activate;
   klass->state_set = state_set;
@@ -648,9 +636,6 @@ gtk_switch_init (GtkSwitch *self)
   gtk_widget_set_has_window (GTK_WIDGET (self), FALSE);
   gtk_widget_set_can_focus (GTK_WIDGET (self), TRUE);
 
-  priv->slider = gtk_gizmo_new ("slider", NULL, NULL, NULL);
-  gtk_widget_set_parent (priv->slider, GTK_WIDGET (self));
-
   gesture = gtk_gesture_multi_press_new (GTK_WIDGET (self));
   gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (gesture), FALSE);
   gtk_gesture_single_set_exclusive (GTK_GESTURE_SINGLE (gesture), TRUE);
@@ -686,6 +671,9 @@ gtk_switch_init (GtkSwitch *self)
    */
   priv->off_label = gtk_label_new (C_("switch", "OFF"));
   gtk_widget_set_parent (priv->off_label, GTK_WIDGET (self));
+
+  priv->slider = gtk_gizmo_new ("slider", NULL, NULL, NULL);
+  gtk_widget_set_parent (priv->slider, GTK_WIDGET (self));
 }
 
 /**